'''import pandas as pd
import numpy as np


# 创建Series
# 从列表创建
s1 = pd.Series([1, 3, 5, np.nan, 6, 8])
print("从列表创建的Series:")
print(s1)

# 从字典创建
s2 = pd.Series({'a': 1, 'b': 2, 'c': 3})
print("\n从字典创建的Series:")
print(s2)

# 从NumPy数组创建
s3 = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
print("\n带自定义索引的Series:")
print(s3)

# Series操作
print(f"\nSeries索引: {s3.index}")
print(f"Series值: {s3.values}")
print(f"前3个元素:\n{s3.head(3)}")
print(f"描述性统计:\n{s3.describe()}")'''




import pandas as pd
import numpy as np
import openpyxl
import fsspec


data = {
    '姓名': ['张三', '李四', '王五', '赵六'],
    '年龄': [25, 30, 35, 28],
    '城市': ['北京', '上海', '广州', '深圳'],
    '薪资': [50000, 60000, 70000, 55000]
}
df = pd.DataFrame(data)
print("从字典创建的DataFrame:")
print(df)

data_list = [
    ['张三', 25, '北京', 50000],
    ['李四', 30, '上海', 60000],
    ['王五', 35, '广州', 70000],
    ['赵六', 28, '深圳', 55000]
]
df2 = pd.DataFrame(data_list, columns=['姓名', '年龄', '城市', '薪资'])
print("\n从列表创建的DataFrame:")
print(df2)

arr = np.random.randn(4, 3)
df3 = pd.DataFrame(arr, columns=['A', 'B', 'C'], index=['行1', '行2', '行3', '行4'])
print("\n从NumPy数组创建的DataFrame:")
print(df3)


df3.to_csv("D:/Program/pycharm/pythonProject/numpydata.csv")
df2.to_excel('D:/Program/pycharm/pythonProject/pandasdata.xlsx')

df_stuinfo = pd.read_csv('D:/Program/pycharm/pythonProject/mystudents.csv', encoding='utf-8-sig')
print(df_stuinfo)
print(df_stuinfo.describe())

print(f"索引是：{df_stuinfo.index}")
print(f"列是： {df_stuinfo.columns}")

print(df_stuinfo['数学成绩'][2])


